package com.qf.hospital.service.impl;

import com.qf.hospital.VO.RegisteredTypeVO;
import com.qf.hospital.entity.RegisteredType;
import com.qf.hospital.mapper.RegisteredTypeMapper;
import com.qf.hospital.service.RegisteredTypeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 何星宇
 * @version V1.0
 * @Date 2021/10/20 15:00
 */
@Service
public class RegisteredTypeServiceImpl implements RegisteredTypeService {
    @Autowired
    private RegisteredTypeMapper mapper;

    /**
     * 查询所有挂号类型
     * @return
     */
    @Override
    public List<RegisteredTypeVO> findAll() {
        List<RegisteredType> registeredTypeList = mapper.selectByExample(null);
        //封装
        List<RegisteredTypeVO> data = new ArrayList<>();
        for (RegisteredType registeredType : registeredTypeList) {
            RegisteredTypeVO registeredTypeVO = new RegisteredTypeVO();
            BeanUtils.copyProperties(registeredType, registeredTypeVO);
            data.add(registeredTypeVO);
        }
        return data;
    }

    /**
     * 查询挂号费用
     * @param registeredId
     * @return
     */
    @Override
    public RegisteredType findById(Integer registeredId) {
        RegisteredType registeredType = mapper.selectByPrimaryKey(registeredId);
        return registeredType;
    }
}
